<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
    //后台接口路由
    Route::group(['namespace' => 'Api'],function(){


    // ================== 不需要Token认证权限的路由 ==================
            //后台登录相关接口
            Route::group(['prefix' => 'auth', 'namespace' => 'Auth'] ,function() {
                //验证登录接口
                Route::post('login', 'LoginController@login');

                //退出登录
                Route::post('logout', 'LoginController@logOut');

            });


    // ================== 需要Token认证的接口路由 ==================
            Route::group(['middleware' => 'refresh.token'], function(){

                //公共接口类
                Route::group(['prefix' => 'common', 'namespace' => 'Common'], function() {
                    //图片上传
                    Route::post('uploadPic', 'UploadController@uploadPic');

                });

                //后台登录相关接口
                Route::group(['prefix' => 'auth', 'namespace' => 'Auth'] ,function(){

                    //获取用户信息接口
                    Route::post('getUser', 'LoginController@getUser');

                 });

                Route::group(['prefix' => 'system', 'namespace' => 'System'], function() {

                    //获取系统配置信息
                    Route::get('getConfig', 'ConfigController@getConfig');
                });


            // ================== 需要权限认证的接口路由 ==================
                Route::group(['middleware' => 'check.permission'], function(){
                    //后台登录相关接口
                    Route::group(['prefix' => 'auth', 'namespace' => 'Auth'] ,function(){

                        //角色控制器
                        Route::resource('role', 'RoleController');

                        //获取角色全部列表
                        Route::get('role_list', 'RoleController@roleList');

                        //权限控制器
                        Route::resource('permission', 'PermissionsController');

                        //用户控制器
                        Route::resource('user', 'UserController');

                    });


                });








                //测试接口
                Route::get('test', 'TestController@test');


            });



    });



